/**
 * Created by Cake on 2017/6/5.
 */

$(function () {

    $('.card-img li').showPicture();

    imgUpload('.add-product-opt input', function (src) {
        var size = $('.add-product-img').length + 1,
            arr = [];
        console.log(size);
        if (size < 4) {
            arr.push('<div class="add-product-img"><p><img src="'+ src +'" alt=""></p><div class="close-img" font="12">×</div></div>');
            $('.add-product-opt').before(arr.join(''));
        } else {
            arr.push('<div class="add-product-img"><p><img src="'+ src +'" alt=""></p><div class="close-img" font="12">×</div></div>');
            $('.add-product-opt').before(arr.join('')).hide();
            alertMsg('图片不能超过4张。')
        }
    });

    $('body').on('click','.close-img',function () {
        $(this).parent().remove();
        $('.add-product-opt').show();
    });

});